<template>
	<view class="">
		<view class="bg-white p-5 flex items-center">
			<u-avatar size="55" :src="getFilePath(user.avatar)"></u-avatar>
			<view class="ml-3">
				<view class="text-lg">{{user.nickName}}</view>
				<view class="text-black-999 text-sm">
					<text class="mr-2">手机号码</text>
					<text>{{formatPhone(user.phonenumber)}}</text>
				</view>
			</view>
		</view>
		<view class="p-5">
			<u-button type="error" @click="onlogout">退出登录</u-button>
		</view>
	</view>
</template>

<script>
	import { mapGetters } from 'vuex'
	import {getFilePath, formatPhone} from '@/utils/index.js'
import { route, showModal } from '../../utils/utils';
	export default {
		data() {
			return {
				
			};
		},
		computed: {
			...mapGetters(['user']),
		},
		
		onLoad() {
			
		},
		methods: {
			getFilePath,
			formatPhone,
			onlogout() {
				showModal({
					content: '确定退出登录吗？'
				}).then(() => {
					console.log('退出')
					this.$store.commit('setToken', '')
					this.$store.commit('setUser', null)
					route('/pages/login/login', 'redirectTo')
				
				})
			},
			toUser() {
				if (this.user) {
					// 跳转到用户中心
				} else {
					uni.navigateTo({
						url: '/package/pages/login/login',
						animationType: 'slide-in-bottom'
					})
				}
			},
		}
	}
</script>

<style lang="scss">

</style>
